home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
ansi
/
use2crts.zip
/
FLIPDOOR.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-11-02
|
7KB
|
234 lines
;RECOVERED FROM THE DEFECTIVE USE2CRTS.LBR
title FLIPDOOR.ASM - Switch Color/Mono Screens on Keyboard Request
; and change active pages on color monitor.
;
;fixed to work with masm 4 (PTRs added)
;
; Courtesy of The Consultants' Exchange BBS (714) 842-6348
; Adapted from DOORS.ASM written by John Dickenson; Published in the
;Feb. 5, 1985 issue of PC Magazine Volume 4 Number 3, pp 273-277, and FLIP.ASM
;From the Feb. 19, 1985 issue of PC Magizine, pp256
;
VECTORS segment at 0h ; 8088 / 80286 Interrup Vector Area
org 9h*4 ; IBM-PC Keyboard is Int 9H
KB_INT_VECTOR label dword ; Double word label
;
VECTORS ends
;
ROM_BIOS_DATA segment at 40h ; Low Memory "BIOS" parameters
;
org 10h ; Location of EQUIP_FLAG
EQUIP_FLAG dw ? ; Contains video settings
; in bits 4 & 5
;
org 17h ; Location of KB_FLAG
KB_FLAG db ? ; Contains Alt )bit 3) &
; Right Shift (bit 0) States
ROM_BIOS_DATA ends
;
; Initialization Routine
;
CODE_SEG segment
assume cs:CODE_SEG
org 100h ; COM program format
BEGIN: jmp SWAP_VECTORS ;Initialize vectors and attach to DOS
;
ROM_KB_INT dd ? ; Double word to save address of
; ROM-BIOS keyboard interrupt
VIDEO_PAGE db ? ; Variable to save active video page
;
FLIP_FLAG db ? ; Variable to indicate video page is
; to be incremented. Bit map follows:
; hi nibble = 0: video page not flipped
; hi nibble = F: video page incremented
; low nibble = 7: monochrome mode
; low nibble = 3: color CRT mode
;
; DOORS_INT intercepts the keyboard interrupt and switches
; screens if [Alt] - [Right Shift] combination is pressed
;
DOORS_INT proc near
assume ds:nothing
push ds ; Push all affected registers
push es
push ax
push bx
push cx
push dx
push si
push di
;
pushf ; Push flags for fake interrupt call
call ROM_KB_INT ; to BIOS program to read keyboard
assume ds:ROM_BIOS_DATA ; Define data segment to read
mov ax,ROM_BIOS_DATA ; Keyboard flag & equipment flag
mov ds,ax
;
; Scan keyboard for Alt - Left Shift & Alt Left Shift
;
mov al,KB_FLAG ; Get keyboard flag
test al,08h ; Alt key pressed?
jz RETURN ; No, quit
test al,02h ; Alt + Left Shift keys pressed?
jnz FLIP_MODE ; Yes, set FLIP_FLAG & monochrome
test al,01h ; Alt + Right Shift keys pressed?
jz RETURN ; No, quit
mov al,00h ; Reset FLIP_FLAG (flipping disabled)
mov FLIP_FLAG,al ; video page remains unchanged
jmp VIDEO_MODE ; Yes, continue processing
;
; FLIP_MODE sets FLIP_FLAG to indicate active video page is to be incremented
;
FLIP_MODE:
mov al,247 ; Set FLIP_FLAG & monochrome
mov FLIP_FLAG,al ; Set flag, indicates that page
; is to be incremented
;
; VIDEO_MODE determens the current display mode (color text or monochrome)
; [Alt] + [Right Shift] or [Left Shift} are pressed -- Continue processing
; Check on video mode -- quit if not monochrome, color 80x25 or BW 80x25
; (Can we switch screens? Not in graphics or 40 column?)
;
VIDEO_MODE:
mov ah,15 ; Call Func 15 of Int 10h to
int 10h ; get video state of PC
mov VIDEO_PAGE,bh ; Save current active page
cmp FLIP_FLAG,240
jae FLIP_FROM_MONO
cmp al,7 ; Is screen monochrome?
je SCREEN_OKAY ; Yes, go switch screens
FLIP_FROM_MONO:
cmp al,3 ; Is screen color text?
jbe CHECK_40_OR_80 ; Yes, go check for 80 or 40 char
jmp RETURN ; Screen is in graphics mode, quit
CHECK_40_OR_80:
cmp al,1 ; Is screen 40-character?
jbe RETURN ; Yes, quit
;
cmp FLIP_FLAG,240 ; FLIP_FLAG set?
jae CHANGE_PAGE ; Yes, change active color video page
jmp SCREEN_OKAY ; No, continue processing DOORS_INT
;
; CHANGE_PAGE will change active color video page and exit
;
CHANGE_PAGE:
inc VIDEO_PAGE
cmp VIDEO_PAGE, 03h ; Check if we're on page 3 (last page)?
jbe FLIP_PAGE ; No, it's ok
mov VIDEO_PAGE,00h ; Yes, reset it to page 0
FLIP_PAGE:
mov al,VIDEO_PAGE ; Call Func 5 of Int 10h to switch
mov ah,5 ; active page on color CRT
int 10h
; below imported from FLIP.ASM
mov ch,23 ; set upper left of window to row 23
mov cl,0 ; and column 0
mov dh,24 ; set lower right of window to row 24
mov dl,79 ; and column 79
mov al,0 ; blank the window
mov bh,7 ; use white on black
mov ah,6 ; perform window scroll (call to BIOS)
int 10h ;
cmp FLIP_FLAG,255 ; Must we switch back to monochrome?
je SWITCH_BACK ; Yes, switch to origional mode
;
RETURN:
pop di ; Restore saved retisters
pop si
pop dx
pop cx
pop bx
pop ax
pop es
pop ds
iret ; Return to system
SWITCH_BACK:
;
SCREEN_OKAY:
;
; Save the current cursor position of active video page
;
mov ah,3 ; Call Func 3 of Int 10h
mov bh,VIDEO_PAGE ; to read cursor position
int 10h ; of active page of color screen
;
; Screen switch routine - Establish calling argument (AL) for Int 10h
; (Establishes which screen to switch to)
;
mov bx, EQUIP_FLAG ; Current equipment flag to BX
mov cx,bx ; Make a copy of it in CX
and cx,30h ; Extract screen information
xor bx,cx ; Erase current screen info in BX
or bx,20h ; Set BX to color 80x25
mov al,3 ; Set AL for color 80x25 in Int 10h
cmp cx,30h ; Is current mono?
je SET_MODE ; Yes, switch to color
or bx,30h ; No, set BX for momochrome
mov al,7 ; Set AL for monochrome in Int 10h
SET_MODE: ; Switch screens
mov EQUIP_FLAG,bx ; Write BX to equipment flag
xor ah,ah ; Use Func 0 of Int 10h to
int 10h ; change screen parameters
;
; Restore cursor
;
mov ah,2 ; Use Func 2 of Int 10h to restore
mov bh,0 ; cursor on new screen (position in DX)
int 10h
;
cmp FLIP_FLAG,255 ; Finished flipping?
je RETURN ; Yes, exit bit-pattern exists
cmp FLIP_FLAG,00h ; Are we in flip mode?
je COPY_SETUP ; No, bypass flip trap
add FLIP_FLAG,8 ; Set FLIP_FLAG to indicate screens have
; been switched
jmp CHANGE_PAGE ;
;
; After Screens are switched, set DS and ES registers to move screen data
;
COPY_SETUP:
mov ax,0b000h ; Load ES with Mono Segment
mov es,ax
mov ax,0b800h ; Load Ds with color segment
mov ds,ax
cmp cx,30h ; Did we switch from mono?
jne COPY_THE_SCREEN ; Yes, move data from mono to color
push ds ;No, swap ES abd DS to move data
push es
pop ds
pop es
COPY_THE_SCREEN:
xor di,di ; Start at zero offsets
xor si,si
mov cx,2000 ; 2000 chars + attrs per screen
cld ; Make sure move is 'forward'
rep movsw ; Move Words with string instruction
jmp RETURN ; Exit
DOORS_INT endp
;
; This procedure initializes the new keyboard interupt vectors
;
SWAP_VECTORS proc near
assume ds:VECTORS
push ds ; Save Data Segment
; for DOS return
mov ax,VECTORS ; Set up the data
mov ds,ax ; segment for vectors
cli ; Disable interrupts
mov ax,WORD PTR KB_INT_VECTOR ; Store addresses
mov WORD PTR ROM_KB_INT,ax ; of BIOS program
mov ax,WORD PTR KB_INT_VECTOR[2]
mov WORD PTR ROM_KB_INT[2],ax
mov WORD PTR KB_INT_VECTOR, offset DOORS_INT ; Substitute Our
mov WORD PTR KB_INT_VECTOR[2],cs ; Program
sti ; Enable interrupts
mov dx,offset SWAP_VECTORS ; End of new resident
; program
int 27h ; Terminate resident
SWAP_VECTORS endp
CODE_SEG ends
end BEGIN
;